import java.util.Scanner;

class Student implements Cloneable{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Example{
    String str = new String("good");
    char[ ] ch = { 'a' , 'b' , 'c' };
    public static void main(String args[]){
        Example ex = new Example();
        ex.change(ex.str,ex.ch);
        System.out.print(ex.str + " and ");
        System.out.print(ex.ch);
    }
    public void change(String str,char ch[ ]){
        str = "test ok";
        ch[0] = 'g';
    }
}

public class Test {

    public static void main(String[] args) {
       /* Student student = new Student("fsfa",1);
        Student student1 = student.clone();
*/

        /*int[] array = {1, 2, 3};
        System.out.printl(array [100]);*/
    }


    public static void func() {
        func();
    }

    public static void main22(String[] args) {

        func();
        //System.out.println(10/0);

        /*int[] array = {1, 2, 3};
        System.out.println(array [100]);*/

        /*int[] array = null;
        System.out.println(array.length);*/
    }

    public static void main20(String[] args) {
        String s1="abc"+"def";//1
        String s2=new String(s1);//2
        if(s1.equals(s2))//3
            System.out.println(".equals succeeded");//4
        if(s1==s2)//5
            System.out.println("==succeeded");//6

    }
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        int i = 0;
        int j = s.length()-1;
        while(i < j) {
            while(i < j && !Character.isLetterOrDigit(s.charAt(i))) {
                i++;
            }
            while(i < j && !Character.isLetterOrDigit(s.charAt(j))) {
                j--;
            }
            if(s.charAt(i) != s.charAt(j)) {
                return false;
            }
            i++;
            j--;
        }
        return true;
    }
    //判断参数字符 是不是数字字符 或者 字母
    private boolean isNumberOrCharacter(char ch) {
        //isDigit 是不是数字字符
        if(Character.isDigit(ch) || Character.isLetter(ch)) {
            return true;
        }
        return false;
    }

    public static void main18(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case

            String str = in.nextLine();

            int index = str.lastIndexOf(" ");

            String ret = str.substring(index+1);

            System.out.print(ret.length());
            // "this is good day"
            // 1. split
            // 2. 找到最后一个空格的位置-》lastIndexof,利用subString（13）
        }
    }

    public static void main17(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case

            String str = in.nextLine();
            String[] ret = str.split(" ");
            System.out.print(ret[ret.length-1].length());
            // "this is good day"
            // 1. split
            // 2. 找到最后一个空格的位置-》lastIndexof,利用subString（13）
        }
    }


    public static void main16(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("abc").append("def");
        stringBuffer.append("hello");
        System.out.println(stringBuffer);

        stringBuffer.reverse();

        System.out.println(stringBuffer);


        String str = stringBuffer.toString();

        String s = "fdsfa";
        //StringBuffer stringBuffer2 = new StringBuffer(s);
        StringBuffer stringBuffer2 = new StringBuffer();
        stringBuffer2.append(s);

    }

    public static void main15(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("abc").append("def");
        stringBuilder.append("hello");
        System.out.println(stringBuilder);

        stringBuilder.reverse();

        System.out.println(stringBuilder);

    }

    public static void main14(String[] args) {
        long start = System.currentTimeMillis();
        String s = "";
        for(int i = 0; i < 10000; ++i){
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);



        start = System.currentTimeMillis();
        StringBuffer sbf = new StringBuffer("");
        for(int i = 0; i < 10000; ++i){
            sbf.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);



        start = System.currentTimeMillis();
        StringBuilder sbd = new StringBuilder();
        for(int i = 0; i < 10000; ++i){
            sbd.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);
    }


    public static void main13(String[] args) {
        String s = "hello";
        s = s + " world";
        System.out.println(s);  // 输出：hello world
    }




    public static void main12(String[] args) {
        final int[] array = {1,2,3,4};
        //array = new int[]{5,6,7,8};
        array[0] = 99;
    }

    public int firstUniqChar(String s) {

        int[] count = new int[26];
        for(int i = 0;i < s.length();i++) {
            char ch = s.charAt(i);
            count[ch-97]++;
        }

        for(int i = 0;i < s.length();i++) {
            char ch = s.charAt(i);
            if(count[ch-97] == 1) {
                return i;
            }
        }

        return -1;
    }

    public static void main11(String[] args) {
        char[] ch = new char[]{'a', 'b', 'c'};
        String s1 = new String(ch);

        s1.intern();

        String s2 = "abc";
        System.out.println(s1 == s2);


        System.out.println("s1地址：0x" + Integer.toHexString(System.identityHashCode(s1)));
        System.out.println("s2地址：0x" + Integer.toHexString(System.identityHashCode(s2)));
    }

    public static void main10(String[] args) {
        char[] ch = new char[]{'a', 'b', 'c'};
        String s1 = new String(ch);

        String s2 = "abc";
        System.out.println(s1 == s2);
    }

    public static void main9(String[] args) {
        /*String str = "abcdef";
        //[1,4)
        String sub = str.substring(1,4);
        System.out.println(sub);
*/

        String str = "   hello  world   " ;
        System.out.println("["+str+"]");
        System.out.println("["+str.trim()+"]");
    }

    public static void main8(String[] args) {
        String str = "name=zhangsan&age=10" ;
        String[] result = str.split("&") ;
        for(String s : result) {
            String[] ss = s.split("=");
            for(String sss : ss) {
                System.out.println(sss);
            }
        }
    }

    public static void main7(String[] args) {
        String str = "name=zhangsan&age=10" ;
        String[] result = str.split("=|&") ;
        for(String s: result) {
            System.out.println(s);
        }
    }

    public static void main6(String[] args) {
        String str = "192.168.1.1" ;
        String[] result = str.split("\\.") ;
        for(String s: result) {
            System.out.println(s);
        }
    }

    public static void main5(String[] args) {
        String str = "hello world hello bit" ;
        String[] result = str.split(" ",2) ; // 按照空格拆分
        for(String s: result) {
            System.out.println(s);
        }
    }

    public static void main4(String[] args) {
        String str = "ababcabcdef";
        //String ret = str.replace('a','p');
        //String ret = str.replace("ab","kkpp");
        String ret = str.replaceAll("ab","kkpp");
        System.out.println(ret);
    }


    public static void main3(String[] args) {
        String str = "abcdef";
        char[] crr = str.toCharArray();
        for(char ch : crr){
            System.out.print(ch+" ");
        }
        System.out.println();


        char[] array = {'a','b','c'};
        String s = new String(array);
        System.out.println(s);


        String s2 = String.format("%d-%d-%d", 2100, 9,14);
        System.out.println(s2);
    }


    public static void main2(String[] args) {
       /* int a = 123;
        String str = String.valueOf(a);
        System.out.println(str);

        System.out.println(String.valueOf(12.4));

        String s4 = String.valueOf(new Student("Hanmeimei", 18));
        System.out.println(s4);
        System.out.println("================");
        int i = Integer.parseInt("123");
        System.out.println(i+1);

        double d = Double.parseDouble("12.45");
        System.out.println(d);
        System.out.println("================");*/
        String str = "hello";
        String ret = str.toUpperCase();
        System.out.println(ret);


        String str2 = "HEllo";
        String ret2 = str2.toLowerCase();
        System.out.println(ret2);
    }
    public static void main1(String[] args) {
        String str="ababcabcdabcdef";
        System.out.println(str.lastIndexOf("abc"));

        //System.out.println(str.indexOf("de",4));

        /*int i=str.indexOf('c',3);
        System.out.println(i);*/

       /* for (int i = 0; i < str.length(); i++) {
            char ch =str.charAt(i);
            System.out.print(ch+" ");
        }*/
    }
}
